//
//  ViewController.m
//  test
//
//  Created by Vincent on 2017/3/25.
//  Copyright © 2017年 Vincent. All rights reserved.
//

#import "ViewController.h"
#import "ZLLBarView.h"




@interface ViewController ()<CALayerDelegate>

@property(nonatomic,strong)ZLLBarView *barV;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    self.barV = [ZLLBarView new];
    self.barV.bounds = CGRectMake(0, 0, 300, 300);
    self.barV.center = self.view.center;
    self.barV.backgroundColor = [UIColor redColor];
    self.barV.titleLab.text = @"test";
    [self.view addSubview:self.barV];
    
}


-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    
    NSMutableArray *dataArr = [NSMutableArray new];
    for(int i=0;i<6;i++){
        
        double yval = arc4random()%101;
        [dataArr addObject:[ZLLBarData barDataWithXDestription:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@",@"test"] attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12],NSForegroundColorAttributeName:[UIColor greenColor]}] yValue:yval barColor:[UIColor blueColor] yBarDescription:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%.2f",yval] attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12],NSForegroundColorAttributeName:[UIColor greenColor]}]]];
    }
    //self.barV.yUnit = [[NSAttributedString alloc] initWithString:@"(%)" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12],NSForegroundColorAttributeName:[UIColor blackColor]}];
    self.barV.yMax = 100;
    self.barV.dataArr = dataArr;
    self.barV.yFormatter = [NSNumberFormatter new];
    //self.barV.yFormatter.numberStyle = NSNumberFormatterPercentStyle;
    self.barV.yFormatter.formatWidth = 4;
    self.barV.yFormatter.multiplier = @1;
    self.barV.yFormatter.roundingMode = NSNumberFormatterRoundUp;
    
    [self.barV strokeBarView];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
